from pyecharts.charts import Map
from pyecharts.options import VisualMapOpts

map_chart = Map()
#准备数据
data = [
    ("北京市", 99),
    ("上海市", 199),
    ("湖南省", 299),
    ("台湾省", 399),
    ("广东省", 599)
]
#添加数据
map_chart.add("测试地图", data, "china")
#设置全局选项
map_chart.set_global_opts(
    visualmap_opts=  VisualMapOpts(is_show=True,
    is_piecewise=True,
    pieces=[
            {"min": 1,"max":199,"label":"1-199","color":"#CCFFFF"},
            {"min": 200,"max":499,"label":"200-499","color":"#FF6666"},
            {"min": 500,"max":999,"label":"500-999","color":"#990033"}
            ]
    )
)
#绘图
map_chart.render()